%This file is for creating a 3D joint-probability-density figure%


% ** Loading data ***//

%load('dat_lsml10000_BNK190a.mat')
%load('dat_lsml10000_EPD190a.mat')


%load('dat_sml10000_BNK190a.mat')
%load('dat_sml10000_EPD190a.mat')

%load('dat_sml10000_BNK190aME90.mat')
%load('dat_sml10000_EPD190aME90.mat')

%load('dat_sml10000_EPD190aLag.mat')

%load('dat_sml10000_EPD190aNoTI.mat')
%load('dat_sml10000_EPD190aNoHB.mat')


%load('dat_sml10000_EPD190aNoTI.mat')



figure(1)
%X=[mtr(:,1) mtr(:,2) mtr(:,3)];
X=[dat(:,1) dat(:,2) dat(:,3)];
edge = linspace(-2,2,500); % change here to your need (-2,2,500);
[count, ~, ~, loc] = histcn(X,edge,edge,edge);
kernel = exp(-linspace(-2,2,11).^2); %(-2,2,11)
K = 1;
for k=1:3
K = K(:)*kernel;
end
K = reshape(K,length(kernel)+[0 0 0 ]);
K = K/sum(K(:));
count = convn(count, K,'same');
density= zeros(size(X,1),1);
valid = all(loc,2);
loc = loc(valid,:);
density(valid) = count(sub2ind(size(count),loc(:,1),loc(:,2),loc(:,3)));
%scatter3(X(:,1),X(:,2),X(:,3),2,density);xlabel('��_b'); ylabel('��_f'); zlabel('��_m_c');grid on; grid minor;
scatter3(X(:,1),X(:,2),X(:,3),2,density);xlabel('��_b'); ylabel('��_f'); zlabel('��_m_c');
colormap(jet)
